package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportWarnRecordDto;
import com.yqg.protection.entity.WarnRecord;
import com.yqg.protection.mapper.WarnRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 16:43
 * description:
 */
@Component
public class WarnRecordListener extends AnalysisEventListener<ImportWarnRecordDto> {

    @Autowired
    private WarnRecordMapper warnRecordMapper;

    @Override
    public void invoke(ImportWarnRecordDto importWarnRecordDto, AnalysisContext analysisContext) {
        WarnRecord warnRecord = new WarnRecord();
        BeanUtil.copyProperties(importWarnRecordDto, warnRecord, true);
        warnRecord.setIsDelete(0);
        warnRecordMapper.insert(warnRecord);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
